
# 读取文件到list
scores = open('score.txt')
lines = scores.readlines()
scores.close()

# 保留结果
result = []

for line in lines:
    stu = line.split()
    # 计算总数
    sum = 0
    for sco in stu[1:]:
        sum += int(sco)
    result.append('%s\t: %d\n' % (stu[0], sum))

# 输出到文件
f = open('score.txt', 'a')
f.write('\n# this is result:\n')
f.writelines(result)

f.close()
